<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>1_props基本使用</title>
</head>
<body>
  <div id="test01"></div>
  <div id="test02"></div>
  <div id="test03"></div>

  <script src="../js/react.development.js"></script>
  <script src="../js/react-dom.development.js"></script>
  <!-- Don't use this in production: -->
  <script src="../js/babel.min.js"></script>

  <script type="text/babel">
    // 创建组件
    class Person extends React.Component {
      render() {
        // console.log(this)
        const {name, sex, age} = this.props
        return (
          <ul>
            <li>姓名：{name}</li>
            <li>性别：{sex}</li>
            <li>年龄：{age}</li>
          </ul>
        )
      }
    }

    // 渲染组件到页面
    ReactDOM.render(<Person name="朱元璋" sex="男" age="30" />, document.getElementById("test01"))
    ReactDOM.render(<Person name="马皇后" sex="女" age="28" />, document.getElementById("test02"))

    const p = {name: "朱棣", sex: "男", age: "4"}
    // console.log(...p)  只支持标签组件
    // ReactDOM.render(<Person name={p.name} sex={p.sex} age={p.age} />, document.getElementById("test03"))
    ReactDOM.render(<Person {...p} />, document.getElementById("test03"))
  </script>
</body>
</html>